<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meat name="viewpoet" content="with=device-width, initial-scale=1.0">
        <title>Document</title>
</head>

<body>
    <div id="app">
        <h3>@keyup.enter -> 监听键盘回车事件</h3>
        //<input @keyup="fn" v-model="username" type="text">
        <input @keyup.enter="fn" v-model="username" type="text">
    </div>
    <!-- 引入的是开发版本包 - 包含完整的注释和警告 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                username: ''
            },
            methods: {
                fn(e) {
                    if (e.key === 'Enter') {
                        //console.log(e)  可以通过e拿到事件对象
                        console.log('键盘回车的时候触发', this.username)
                    }

                }
            }
        })
    </script>

</body>

</html>